
const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Node)
    itemTemplate: cc.Node = null;

    @property(cc.ScrollView)
    scrollView: cc.ScrollView = null;

    @property
    spawnCount: number = 0; // how many items we actually spawn

    content: cc.Node = null;
    updateTimer: number = 0
    updateInterval: number = 0.2
    
    onLoad() {
        this.content = this.scrollView.content;
        this.initialize();
    }

    // 
    initialize() {
        for (let i = 0; i < this.spawnCount; ++i) { 
            let item = cc.instantiate(this.itemTemplate);
            this.content.addChild(item);
            item.x=0;
            //item.setPosition(0, -item.height * (0.5 + i) - this.spacing * (i + 1));
            item.getComponent('Item2').initItem(i, i);
        }
    }

    update(dt) {
        this.updateTimer += dt;
        if (this.updateTimer < this.updateInterval) {
            return;
        }     
    }
    addItem() {
    }
}

